import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import render from '@dfeidao/atom-mobile/render/render';

const REQUEST_URL = 'https://raw.githubusercontent.com/facebook/react-native/0.51-stable/docs/MoviesExample.json';

async function get(url: string) {
	return new Promise((resolve) => {

		fetch(url)
			.then((response) => response.json())
			.then((responseData) => {
				resolve(responseData);
			});
	});
}

export default async function a002(fd: IFeidaoAiMobile) {
	const data = await get(REQUEST_URL) as { movies: [] };
	render(fd, {
		movies: data.movies
	});
}
